# -*- coding: utf-8 -*-
"""
@Time ： 2023/10/10 14:45
@Auth ： y.h
@File ：pandas_query_controller.py
@IDE ：PyCharm
@Motto：The sooner you start to code, the longer the program will take. —— Roy Carlson
"""
import pandas
import pandas as pd

from pythonProjectTemplate.Entity.SystemEntity.data_duplicate_checking_entity import 数据查重配置文件
from pythonProjectTemplate.Entity.SystemEntity.get_sheet_data_value_entity import 数据裁切配置文件
from pythonProjectTemplate.Service.DataAnalysis.data_analysis import data_group_by_query
from pythonProjectTemplate.Service.DataCleansing.data_cleansing import data_deduplication, table_merge
from pythonProjectTemplate.Utils.pandas_utils import get_sheet_data, get_row_count, get_col_count, condition_query, \
    fuzzy_query


# todo 如果有时间优化,试试查询功能能不能用myBatis-plus的wrapper结构封装
class pandas数据筛查:
    def 数据查重(self, data_dict, properties: list[数据查重配置文件]):
        return data_deduplication(data_dict, properties)

    def 数据截取(self, data_dict: dict, properties: 数据裁切配置文件) -> dict:
        return get_sheet_data(data_dict, properties)

    def 合并表(self, df_list: list, link_list: list, link_func: str):
        return table_merge(df_list, link_list, link_func)

    def 指定列值筛查(self, df, col_value: str, value_list: list):
        df: pandas.DataFrame
        return df.loc[df[col_value].isin(value_list)]

    def 条件查询(self, df, query_condition):
        return condition_query(df, query_condition)

    def 获取行数(self, df):
        return get_row_count(df)

    def 获取列数(self, df):
        return get_col_count(df)

    def 分组查询(self, df, group_col_name: str):
        return data_group_by_query(df, group_col_name)

    def 类型数量统计(self, df):
        pass

    def 模糊查询(self, df, col_name: str, like_value: str):
        return fuzzy_query(df,col_name,like_value)
